#include "stdafx.h"
#include "wf_actionfactory.h"

#include <QDockWidget>
#include <QToolBar>

#include "wf_blockscreate.h"
#include "wf_blocksfreezeall.h"
#include "wf_blocksadd.h"
#include "wf_blocksremove.h"
#include "wf_blocksattributes.h"
#include "wf_blocksedit.h"
#include "wf_blocksinsert.h"
#include "wf_blockstoggleview.h"
#include "wf_blocksexplode.h"
#include "wf_dimaligned.h"
#include "wf_dimangular.h"
#include "wf_dimdiametric.h"
#include "wf_dimleader.h"
#include "wf_dimlinear.h"
#include "wf_dimradial.h"
#include "wf_drawarc.h"
#include "wf_drawarc3p.h"
#include "wf_drawcircle.h"
#include "wf_drawcircle2p.h"
#include "wf_drawcircle3p.h"
#include "wf_drawcirclecr.h"
#include "wf_drawellipseaxis.h"
#include "wf_drawhatch.h"
#include "wf_drawimage.h"
#include "wf_drawline.h"
#include "wf_drawlineangle.h"
#include "wf_drawlinebisector.h"
#include "wf_drawlinefree.h"
#include "wf_drawlinehorvert.h"
#include "wf_drawlineparallel.h"
#include "wf_drawlineparallelthrough.h"
#include "wf_drawlinepolygon.h"
#include "wf_drawlinepolygon2.h"
#include "wf_drawlinerectangle.h"
#include "wf_drawlinerelangle.h"
#include "wf_drawlinetangent1.h"
#include "wf_drawlinetangent2.h"
#include "wf_drawpoint.h"
#include "wf_drawspline.h"
#include "wf_drawtext.h"
#include "wf_editcopy.h"
#include "wf_editpaste.h"
#include "wf_editundo.h"
#include "wf_filenew.h"
#include "wf_fileopen.h"
#include "wf_filesave.h"
#include "wf_filesaveas.h"
#include "wf_infoangle.h"
#include "wf_infodist.h"
#include "wf_infodist2.h"
#include "wf_infoinside.h"
#include "wf_infototallength.h"
#include "wf_layersadd.h"
#include "wf_layersedit.h"
#include "wf_layersfreezeall.h"
#include "wf_layersremove.h"
#include "wf_layerstogglelock.h"
#include "wf_layerstoggleview.h"
#include "wf_lockrelativezero.h"
#include "wf_modifyattributes.h"
#include "wf_modifybevel.h"
#include "wf_modifymirror.h"
#include "wf_modifycut.h"
#include "wf_modifydelete.h"
#include "wf_modifydeletefree.h"
#include "wf_modifydeletequick.h"
#include "wf_modifyentity.h"
#include "wf_modifymove.h"
#include "wf_modifymoverotate.h"
#include "wf_modifyrotate.h"
#include "wf_modifyrotate2.h"
#include "wf_modifyround.h"
#include "wf_modifyscale.h"
#include "wf_modifystretch.h"
#include "wf_modifytrim.h"
#include "wf_modifytrimamount.h"
#include "wf_modifyexplodetext.h"
#include "wf_optionsdrawing.h"
#include "wf_printpreview.h"
#include "wf_selectall.h"
#include "wf_selectintersected.h"
#include "wf_selectinvert.h"
#include "wf_selectlayer.h"
#include "wf_selectsingle.h"
#include "wf_selectcontour.h"
#include "wf_selectwindow.h"
#include "wf_setrelativezero.h"
#include "wf_snapintersectionmanual.h"
#include "wf_toolregeneratedimensions.h"
#include "wf_zoomauto.h"
#include "wf_zoomprevious.h"
#include "wf_zoomin.h"
#include "wf_zoompan.h"
#include "wf_zoomredraw.h"
#include "wf_zoomwindow.h"
#include "wf_drawpolyline.h"

#include "wf_polylineadd.h"
#include "wf_polylinedel.h"
#include "wf_polylinedelbetween.h"
#include "wf_polylinetrim.h"


/**
 * Constructor.
 *
 * @param ah Action handler which provides the slots.
 * @param w Widget through which the events come in.
 */
WF_ActionFactory::WF_ActionFactory(WF_ActionHandler* ah, QWidget* w) {
    actionHandler = ah;
    widget = w;
}



/**
 * Destructor
 */
WF_ActionFactory::~WF_ActionFactory() {}



/**
 * Creates a new action object and links it to the appropriate slot(s).
 *
 * @param id ID of the action to create (see rs.h).
 * @param obj Object which the action will connect its signal to.
 *
 * @return Pointer to the action object or NULL if the action is unknown.
 */
QAction* WF_ActionFactory::createAction(LX_Define::ActionType id, QObject* obj, QObject* obj2) {
    // assert that action handler is not invalid:
    if (actionHandler==NULL) {
        PF_DEBUG->print(PF_Debug::D_WARNING,
        	"QG_ActionFactory::createAction: "
			"No valid action handler available to create action. id: %d", id);
        return NULL;
    }

    QWidget* mw = widget;
    QAction* action = NULL;
    QPixmap icon;

    if (mw==NULL) {
        PF_DEBUG->print(PF_Debug::D_WARNING,
        	"QG_ActionFactory::createAction: "
			"No valid main window available to create action. id: %d ", id);
        return NULL;
    }

    // create requested action
    switch (id) {

        // File actions:
        //
    case LX_Define::ActionFileNew:
		action = WF_FileNew::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotFileNew()));
        break;

    case LX_Define::ActionFileOpen:
		action = WF_FileOpen::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotFileOpen()));
        break;

    case LX_Define::ActionFileSave:
		action = WF_FileSave::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotFileSave()));
        break;

    case LX_Define::ActionFileSaveAs:
		action = WF_FileSaveAs::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotFileSaveAs()));
        break;

    case LX_Define::ActionFileExport:
			// tr("Export Drawing")
			action = new QAction(tr("&Export..."), NULL);
			//action->zetStatusTip(tr("Exports the current drawing as bitmap"));			
			
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotFileExport()));
        break;

    case LX_Define::ActionFileClose:
			// tr("Close Drawing")
			action = new QAction(tr("&Close"), mw);
			action->setIcon(QIcon(":/actions/fileclose.png"));
			action->setShortcut(QKeySequence::Close);
			//action->zetStatusTip(tr("Closes the current drawing"));			
			connect(action, SIGNAL(activated()),
                obj, SLOT(slotFileClose()));
        break;

    case LX_Define::ActionFilePrint:			
			// tr("Print Drawing")
			action = new QAction(tr("&Print..."), mw);
#if QT_VERSION >= 0x040600
                        action->setIcon(QIcon::fromTheme("document-print", QIcon(":/actions/fileprint.png")));
#else
                        action->setIcon(QIcon(":/actions/fileprint.png"));
#endif
			action->setShortcut(QKeySequence::Print);
			//action->zetStatusTip(tr("Prints out the current drawing"));
			
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotFilePrint()));
        break;

    case LX_Define::ActionFilePrintPreview:
		action = WF_PrintPreview::createGUIAction(id, mw);
		action->setToggleAction(true);
        connect(action, SIGNAL(toggled(bool)),
                obj, SLOT(slotFilePrintPreview(bool)));
        break;

    case LX_Define::ActionFileQuit:
                        action = new QAction(tr("&Quit"), mw);
#if QT_VERSION >= 0x040600
                        action->setIcon(QIcon::fromTheme("application-exit", QIcon(":/actions/exit.png")));
                        action->setShortcut(QKeySequence::Quit);
#else
                        action->setIcon(QIcon(":/actions/exit.png"));
#endif
			//action->zetStatusTip(tr("Quits the application"));
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotFileQuit()));
        break;

        // Viewing actions:
        //
    case LX_Define::ActionViewGrid:
			// tr("Grid")
			action = new QAction(tr("&Grid"), mw);
			action->setIcon(QIcon(":/actions/viewgrid.png"));
			action->setShortcut(tr("CTRL-G"));
			//action->zetStatusTip(tr("Enables/disables the grid"));
			action->setCheckable(true);
			connect(action, SIGNAL(toggled(bool)),
                obj, SLOT(slotViewGrid(bool)));
        break;
    case LX_Define::ActionViewDraft:
			// tr("Draft")
			action = new QAction(tr("&Draft"), mw);
			action->setIcon(QIcon(":/actions/viewdraft.png"));
			//action->zetStatusTip(tr("Enables/disables the draft mode"));
			action->setCheckable(true);			
			connect(action, SIGNAL(toggled(bool)),
                obj, SLOT(slotViewDraft(bool)));
        break;
    case LX_Define::ActionViewStatusBar:
        // tr("Statusbar")
        action = new QAction(tr("&Statusbar"), mw);
        //action->zetStatusTip(tr("Enables/disables the statusbar"));
        action->setCheckable(true);

        connect(action, SIGNAL(toggled(bool)),
                obj, SLOT(slotViewStatusBar(bool)));
        break;

    case LX_Define::ActionViewLayerList:
    case LX_Define::ActionViewBlockList:
    case LX_Define::ActionViewCommandLine:
    case LX_Define::ActionViewLibrary:
        if (obj2) {
            action=((QDockWidget *)obj2)->toggleViewAction();
        }
        break;

    case LX_Define::ActionViewPenToolbar:
    case LX_Define::ActionViewOptionToolbar:
    case LX_Define::ActionViewCadToolbar:
    case LX_Define::ActionViewFileToolbar:
    case LX_Define::ActionViewEditToolbar:
        if (obj2) {
            action=((QToolBar *)obj2)->toggleViewAction();
        }
        break;

        // Tools:
        //
    case LX_Define::ActionToolRegenerateDimensions:
		action = WF_ToolRegenerateDimensions::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotToolRegenerateDimensions()));
        break;

        // Zooming actions:
        //
    case LX_Define::ActionZoomIn:
		action = WF_ZoomIn::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotZoomIn()));
        break;

    case LX_Define::ActionZoomOut:
		action = WF_ZoomIn::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotZoomOut()));
        break;

    case LX_Define::ActionZoomAuto:
		action = WF_ZoomAuto::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotZoomAuto()));
        break;

    case LX_Define::ActionZoomWindow:
		action = WF_ZoomWindow::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotZoomWindow()));
        break;

    case LX_Define::ActionZoomPan:
		action = WF_ZoomPan::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotZoomPan()));
        break;
    
	case LX_Define::ActionZoomPrevious:
		action = WF_ZoomPrevious::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotZoomPrevious()));
        break;

    case LX_Define::ActionZoomRedraw:
		action = WF_ZoomRedraw::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotZoomRedraw()));
        break;

        // Editing actions:
        //
    case LX_Define::ActionEditKillAllActions:
        action = new QAction(tr("&back"), mw);
#if QT_VERSION >= 0x040600
        action->setIcon(QIcon::fromTheme("go-previous-view", QIcon(":/actions/back.png")));
#else
        action->setIcon(QIcon(":/actions/back.png"));
#endif
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotEditKillAllActions()));
        break;
    case LX_Define::ActionEditUndo:
        action = WF_EditUndo::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotEditUndo()));
        break;

    case LX_Define::ActionEditRedo:
		action = WF_EditUndo::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotEditRedo()));
        break;

    case LX_Define::ActionEditCut:
		action = WF_EditCopy::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotEditCut()));
        break;

    case LX_Define::ActionEditCopy:
		action = WF_EditCopy::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotEditCopy()));
        break;

    case LX_Define::ActionEditPaste:
		action = WF_EditPaste::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotEditPaste()));
        break;

        // Selecting actions:
        //
    case LX_Define::ActionSelectSingle:
		action = WF_SelectSingle::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSelectSingle()));
        break;

    case LX_Define::ActionSelectWindow:
		action = WF_SelectWindow::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSelectWindow()));
        break;

    case LX_Define::ActionDeselectWindow:
		action = WF_SelectWindow::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDeselectWindow()));
        break;

    case LX_Define::ActionSelectContour:
		action = WF_SelectContour::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSelectContour()));
        break;

    case LX_Define::ActionSelectAll:
		action = WF_SelectAll::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSelectAll()));
        break;

    case LX_Define::ActionDeselectAll:
		action = WF_SelectAll::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDeselectAll()));
        break;

    case LX_Define::ActionSelectInvert:
		action = WF_SelectInvert::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSelectInvert()));
        break;

    case LX_Define::ActionSelectIntersected:
		action = WF_SelectIntersected::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSelectIntersected()));
        break;

    case LX_Define::ActionDeselectIntersected:
		action = WF_SelectIntersected::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDeselectIntersected()));
        break;

    case LX_Define::ActionSelectLayer:
		action = WF_SelectLayer::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSelectLayer()));
        break;

        // Drawing actions:
        //
    case LX_Define::ActionDrawPoint:
		action = WF_DrawPoint::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawPoint()));
        break;

    case LX_Define::ActionDrawLine:
		action = WF_DrawLine::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLine()));
        break;

    case LX_Define::ActionDrawLineAngle:
		action = WF_DrawLineAngle::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineAngle()));
        break;

    case LX_Define::ActionDrawLineHorizontal:
		action = WF_DrawLineAngle::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineHorizontal()));
        break;

    case LX_Define::ActionDrawLineHorVert:
		action = WF_DrawLineHorVert::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineHorVert()));
        break;

    case LX_Define::ActionDrawLineVertical:
		action = WF_DrawLineAngle::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineVertical()));
        break;

    case LX_Define::ActionDrawLineFree:
		action = WF_DrawLineFree::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineFree()));
        break;

    case LX_Define::ActionDrawLineParallel:
		action = WF_DrawLineParallel::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineParallel()));
        break;

    case LX_Define::ActionDrawLineParallelThrough:
		action = WF_DrawLineParallelThrough::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineParallelThrough()));
        break;

    case LX_Define::ActionDrawLineRectangle:
		action = WF_DrawLineRectangle::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineRectangle()));
        break;

    case LX_Define::ActionDrawLineBisector:
		action = WF_DrawLineBisector::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineBisector()));
        break;

    case LX_Define::ActionDrawLineTangent1:
		action = WF_DrawLineTangent1::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineTangent1()));
        break;

    case LX_Define::ActionDrawLineTangent2:
		action = WF_DrawLineTangent2::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineTangent2()));
        break;

    case LX_Define::ActionDrawLineOrthogonal:
		action = WF_DrawLineRelAngle::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineOrthogonal()));
        break;

    case LX_Define::ActionDrawLineRelAngle:
		action = WF_DrawLineRelAngle::createGUIAction(id, mw);
		/*
        action = new QAction(tr("Relative angle"), tr("R&elative angle"),
                             0, mw);
        //action->zetStatusTip(tr("Draw line with relative angle"));
		*/
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLineRelAngle()));
        break;

    case LX_Define::ActionDrawPolyline:
		action = WF_DrawPolyline::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawPolyline()));
        break;
		
    case LX_Define::ActionDrawLinePolygon:
		action = WF_DrawLinePolygon::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLinePolygon()));
        break;

    case LX_Define::ActionDrawLinePolygon2:
		action = WF_DrawLinePolygon::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawLinePolygon2()));
        break;

    case LX_Define::ActionDrawCircle:
		action = WF_DrawCircle::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawCircle()));
        break;

    case LX_Define::ActionDrawCircleCR:
		action = WF_DrawCircleCR::createGUIAction(id, mw);
		/*
        action = new QAction(tr("Circle: Center, Radius"),
                             tr("Center, &Radius"),
                             0, mw);
        //action->zetStatusTip(tr("Draw circles with center and radius"));
		*/
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawCircleCR()));
        break;

    case LX_Define::ActionDrawCircle2P:
		action = WF_DrawCircle2P::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawCircle2P()));
        break;

    case LX_Define::ActionDrawCircle3P:
		action = WF_DrawCircle3P::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawCircle3P()));
        break;

    case LX_Define::ActionDrawCircleParallel:
		action = WF_DrawLineParallel::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawCircleParallel()));
        break;

    case LX_Define::ActionDrawArc:
		action = WF_DrawArc::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawArc()));
        break;

    case LX_Define::ActionDrawArc3P:
		action = WF_DrawArc3P::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawArc3P()));
        break;

    case LX_Define::ActionDrawArcParallel:
		action = WF_DrawLineParallel::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawArcParallel()));
        break;

    case LX_Define::ActionDrawEllipseAxis:
		action = WF_DrawEllipseAxis::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawEllipseAxis()));
        break;

    case LX_Define::ActionDrawEllipseArcAxis:
		action = WF_DrawEllipseAxis::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawEllipseArcAxis()));
        break;
		
    case LX_Define::ActionDrawSpline:
		action = WF_DrawSpline::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawSpline()));
        break;
    
	case LX_Define::ActionPolylineAdd:
		action = WF_PolylineAdd::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotPolylineAdd()));
        break;
	
	case LX_Define::ActionPolylineDel:
		action = WF_PolylineDel::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotPolylineDel()));
        break;
	
	case LX_Define::ActionPolylineDelBetween:
		action = WF_PolylineDelBetween::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotPolylineDelBetween()));
        break;
	
	case LX_Define::ActionPolylineTrim:
		action = WF_PolylineTrim::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotPolylineTrim()));
        break;

    case LX_Define::ActionDrawText:
		action = WF_DrawText::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawText()));
        break;
	/*
    case LX_Define::ActionDrawHatch:
		action = PF_ActionDrawHatch::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawHatch()));
        break;

    case LX_Define::ActionDrawImage:
		action = PF_ActionDrawImage::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDrawImage()));
        break;*/

        // Dimensioning actions:
        //
    case LX_Define::ActionDimAligned:
		action = WF_DimAligned::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDimAligned()));
        break;

    case LX_Define::ActionDimLinear:
		action = WF_DimLinear::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDimLinear()));
        break;

    case LX_Define::ActionDimLinearHor:
		action = WF_DimLinear::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDimLinearHor()));
        break;

    case LX_Define::ActionDimLinearVer:
		action = WF_DimLinear::createGUIAction(id, mw);
		
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDimLinearVer()));
        break;

    case LX_Define::ActionDimRadial:
		action = WF_DimRadial::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDimRadial()));
        break;

    case LX_Define::ActionDimDiametric:
		action = WF_DimDiametric::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDimDiametric()));
        break;

    case LX_Define::ActionDimAngular:
		action = WF_DimAngular::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDimAngular()));
        break;

    case LX_Define::ActionDimLeader:
		action = WF_DimLeader::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotDimLeader()));
        break;

        // Modifying actions:
        //
    case LX_Define::ActionModifyAttributes:
		action = WF_ModifyAttributes::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyAttributes()));
        break;
    case LX_Define::ActionModifyDelete:
		action = WF_ModifyDelete::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyDelete()));
        break;

    case LX_Define::ActionModifyDeleteQuick:
		action = WF_ModifyDeleteQuick::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyDeleteQuick()));
        break;

    case LX_Define::ActionModifyDeleteFree:
		action = WF_ModifyDeleteFree::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyDeleteFree()));
        break;

    case LX_Define::ActionModifyMove:
		action = WF_ModifyMove::createGUIAction(id, mw);
		/*
        action = new QAction(tr("Move"), tr("&Move"),
                             0, mw);
        //action->zetStatusTip(tr("Move Entities"));
		*/
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyMove()));
        break;

    case LX_Define::ActionModifyRotate:
		action = WF_ModifyRotate::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyRotate()));
        break;

    case LX_Define::ActionModifyScale:
		action = WF_ModifyScale::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyScale()));
        break;

    case LX_Define::ActionModifyMirror:
		action = WF_ModifyMirror::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyMirror()));
        break;

    case LX_Define::ActionModifyMoveRotate:
		action = WF_ModifyMoveRotate::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyMoveRotate()));
        break;

    case LX_Define::ActionModifyRotate2:
                action = WF_ModifyRotate2::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyRotate2()));
        break;

    case LX_Define::ActionModifyEntity:
		action = WF_ModifyEntity::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyEntity()));
        break;

    case LX_Define::ActionModifyTrim:
		action = WF_ModifyTrim::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyTrim()));
        break;

    case LX_Define::ActionModifyTrim2:
		action = WF_ModifyTrim::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyTrim2()));
        break;

    case LX_Define::ActionModifyTrimAmount:
		action = WF_ModifyTrimAmount::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyTrimAmount()));
        break;

    case LX_Define::ActionModifyCut:
		action = WF_ModifyCut::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyCut()));
        break;

    case LX_Define::ActionModifyStretch:
		action = WF_ModifyStretch::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyStretch()));
        break;

    case LX_Define::ActionModifyBevel:
		action = WF_ModifyBevel::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyBevel()));
        break;

    case LX_Define::ActionModifyRound:
		action = WF_ModifyRound::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyRound()));
        break;

    case LX_Define::ActionModifyExplodeText:
		action = WF_ModifyExplodeText::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotModifyExplodeText()));
        break;

        // Snapping actions:
        //
    case LX_Define::ActionSnapFree:
		// tr("Free")
		action = new QAction(tr("&Free"), mw);
        //action->zetStatusTip(tr("Free positioning"));
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/snapfree.png"));
        actionHandler->setActionSnapFree(action);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSnapFree()));
        break;

    case LX_Define::ActionSnapGrid:
		// tr("Grid")
		action = new QAction(tr("&Grid"),  mw);
        //action->zetStatusTip(tr("Grid positioning"));
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/snapgrid.png"));
        actionHandler->setActionSnapGrid(action);			
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSnapGrid()));
        break;

    case LX_Define::ActionSnapEndpoint:
		//	tr("Endpoints")			
		action = new QAction(tr("&Endpoints"),mw); 
        //action->zetStatusTip(tr("Snap to endpoints"));
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/snapendpoint.png"));
		actionHandler->setActionSnapEndpoint(action);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSnapEndpoint()));
        break;

    case LX_Define::ActionSnapOnEntity:
		// tr("&n Entity")
		action = new QAction(tr("&On Entity"),  mw);
        //action->zetStatusTip(tr("Snap to nearest point on entity"));
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/snaponentity.png"));
        actionHandler->setActionSnapOnEntity(action);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSnapOnEntity()));
        break;

    case LX_Define::ActionSnapCenter:
		// tr("Center")
		action = new QAction(tr("&Center"), mw);
        //action->zetStatusTip(tr("Snap to centers"));
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/snapcenter.png"));
        actionHandler->setActionSnapCenter(action);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSnapCenter()));
        break;

    case LX_Define::ActionSnapMiddle:
		// tr("Middle")
		action = new QAction(tr("&Middle"), mw);
        //action->zetStatusTip(tr("Snap to middle points"));
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/snapmiddle.png"));
        actionHandler->setActionSnapMiddle(action);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSnapMiddle()));
        break;

    case LX_Define::ActionSnapDist:
		// tr("Distance from Endpoint")
		action = new QAction(tr("&Distance from Endpoint"),mw);
		//action->zetStatusTip(tr("Snap to points with a given distance to an endpoint"));
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/snapdist.png"));
        actionHandler->setActionSnapDist(action);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSnapDist()));
        break;

    case LX_Define::ActionSnapIntersection:
		// tr("Intersection")
		action = new QAction(tr("&Intersection"), mw);
        //action->zetStatusTip(tr("Snap to intersection points"));
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/snapintersection.png"));
        actionHandler->setActionSnapIntersection(action);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSnapIntersection()));
        break;

    case LX_Define::ActionSnapIntersectionManual:
		action = WF_SnapIntersectionManual::createGUIAction(id, mw);
        actionHandler->setActionSnapIntersectionManual(action);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSnapIntersectionManual()));
        break;

        // Snap restriction actions:
        //
    case LX_Define::ActionRestrictNothing:
		// tr("Restrict Nothing")
		action = new QAction(tr("Restrict &Nothing"), mw);
        //action->zetStatusTip(tr("No snap restriction"));
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/restrictnothing.png"));
        actionHandler->setActionRestrictNothing(action);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotRestrictNothing()));
        break;

    case LX_Define::ActionRestrictOrthogonal:
		// tr("Restrict Orthogonally")
		action = new QAction(tr("Restrict &Orthogonally"),mw);
		//action->zetStatusTip(tr("Restrict snapping orthogonally"));
        actionHandler->setActionRestrictOrthogonal(action);
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/restrictorthogonal.png"));
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotRestrictOrthogonal()));
        break;

    case LX_Define::ActionRestrictHorizontal:
		// (tr("Restrict Horizontally")
		action = new QAction(tr("Restrict &Horizontally"), mw);
		//action->zetStatusTip(tr("Restrict snapping horizontally"));
        actionHandler->setActionRestrictHorizontal(action);
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/restricthorizontal.png"));
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotRestrictHorizontal()));
        break;

    case LX_Define::ActionRestrictVertical:
		// tr("Restrict Vertically")
		action = new QAction(tr("Restrict&Vertically"), mw);
		//action->zetStatusTip(tr("Restrict snapping vertically"));
        actionHandler->setActionRestrictVertical(action);
		action->setCheckable(true);
		action->setIcon(QIcon(":/extui/restrictvertical.png"));
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotRestrictVertical()));
        break;

        // Relative zero point
        //
    case LX_Define::ActionSetRelativeZero:
		action = WF_SetRelativeZero::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotSetRelativeZero()));
        break;
    case LX_Define::ActionLockRelativeZero:
		action = WF_LockRelativeZero::createGUIAction(id, mw);
        actionHandler->setActionLockRelativeZero(action);
        connect(action, SIGNAL(toggled(bool)),
                obj, SLOT(slotLockRelativeZero(bool)));
        break;

        // Info actions:
        //
    case LX_Define::ActionInfoInside:
		action = WF_InfoInside::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotInfoInside()));
        break;

    case LX_Define::ActionInfoDist:
		action = WF_InfoDist::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotInfoDist()));
        break;

    case LX_Define::ActionInfoDist2:
		action = WF_InfoDist2::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotInfoDist2()));
        break;

    case LX_Define::ActionInfoAngle:
		action = WF_InfoAngle::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotInfoAngle()));
        break;
		
    case LX_Define::ActionInfoTotalLength:
		action = WF_InfoTotalLength::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotInfoTotalLength()));
        break;

        // Layer actions:
        //
    case LX_Define::ActionLayersDefreezeAll:
		action = WF_LayersFreezeAll::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotLayersDefreezeAll()));
        break;
    case LX_Define::ActionLayersFreezeAll:
		action = WF_LayersFreezeAll::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotLayersFreezeAll()));
        break;
    case LX_Define::ActionLayersAdd:
		action = WF_LayersAdd::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotLayersAdd()));
        break;

    case LX_Define::ActionLayersRemove:
		action = WF_LayersRemove::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotLayersRemove()));
        break;

    case LX_Define::ActionLayersEdit:
		action = WF_LayersEdit::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotLayersEdit()));
        break;
		
    case LX_Define::ActionLayersToggleLock:
		action = WF_LayersToggleLock::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotLayersToggleView()));
        break;

    case LX_Define::ActionLayersToggleView:
		action = WF_LayersToggleView::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotLayersToggleView()));
        break;

        // Block actions:
        //
    case LX_Define::ActionBlocksDefreezeAll:
		action = WF_BlocksFreezeAll::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksDefreezeAll()));
        break;
    case LX_Define::ActionBlocksFreezeAll:
		action = WF_BlocksFreezeAll::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksFreezeAll()));
        break;
    case LX_Define::ActionBlocksAdd:
		action = WF_BlocksAdd::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksAdd()));
        break;
    case LX_Define::ActionBlocksRemove:
		action = WF_BlocksRemove::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksRemove()));
        break;
    case LX_Define::ActionBlocksAttributes:
		action = WF_BlocksAttributes::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksAttributes()));
        break;
    case LX_Define::ActionBlocksEdit:
		action = WF_BlocksEdit::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksEdit()));
        break;
    case LX_Define::ActionBlocksInsert:
		action = WF_BlocksInsert::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksInsert()));
        break;
    case LX_Define::ActionBlocksToggleView:
		action = WF_BlocksToggleView::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksToggleView()));
        break;
    case LX_Define::ActionBlocksCreate:
		action = WF_BlocksCreate::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksCreate()));
        break;
    case LX_Define::ActionBlocksExplode:
		action = WF_BlocksExplode::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotBlocksExplode()));
        break;
		

        // Options actions:
        //
    case LX_Define::ActionOptionsGeneral:
/*          action = new QAction(tr("Application"), qPixmapFromMimeSource("configure.png"),
#ifdef __APPLE__
							 tr("&Preferences"),
#else
                             tr("&Application Preferences")+"...",
#endif
                             0, mw); */

                        action = new QAction(QIcon(":/actions/configure.png"),
#ifdef __APPLE__
								 tr("&Preferences"),
#else
								 tr("&Application Preferences")+"...",
#endif
								 mw);
			
			
			//action->zetStatusTip(tr("General Application Preferences"));
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotOptionsGeneral()));
        break;

    case LX_Define::ActionOptionsDrawing:
		action = WF_OptionsDrawing::createGUIAction(id, mw);
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotOptionsDrawing()));
        break;
		
        // Scripting actions:
        //
	case LX_Define::ActionScriptOpenIDE:
			/*  
			action = new QAction(tr("Open IDE"),
								 tr("&Open IDE"),
								 0, mw); */
			action = new QAction(tr("Open IDE"), mw);
			//action->zetStatusTip(tr("Opens the integrated development environment for scripting"));
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotScriptOpenIDE()));
		break;
		
	case LX_Define::ActionScriptRun:
/*  			action = new QAction(tr("Run Script.."),
								 tr("&Run Script.."),
								 0, mw); */
			action = new QAction(tr("Run Script.."), mw);
			//action->zetStatusTip(tr("Runs a script"));
        connect(action, SIGNAL(activated()),
                obj, SLOT(slotScriptRun()));
		break;

	
    default:
        PF_DEBUG->print(PF_Debug::D_WARNING,
        	"No action %d defined", id);
		assert(true);
        break;
    }

    return action;
}


